package com.example.weizix.ui.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.weizix.R;
import com.example.weizix.base.BaseLazyLoadFragment;
import com.example.weizix.bean.columnBean;
import com.example.weizix.presenter.SectionsPresenter;
import com.example.weizix.ui.adapter.CoumnAdapter;
import com.example.weizix.view.SectionsView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * A simple {@link Fragment} subclass.
 */
public class SectionsFragment extends BaseLazyLoadFragment<SectionsPresenter> implements SectionsView {

    private CoumnAdapter adapter;
//    @BindView(R.id.rel)
//    RecyclerView rel;
    public SectionsFragment() {
        // Required empty public constructor
    }

    public static BaseLazyLoadFragment getInstance() {
        SectionsFragment fragment = new SectionsFragment();
        return fragment;
    }

    @Override
    protected int getLayout() {
        return R.layout.fragment_sections;
    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initData() {
        mPresenter.getSectIon();
    }

    @Override
    protected void initView(View inflate) {
        RecyclerView rel = inflate.findViewById(R.id.rel);
        rel.setLayoutManager(new GridLayoutManager(getActivity(),2));
        ArrayList<columnBean.DataBean> list = new ArrayList<>();
        adapter = new CoumnAdapter(getContext(),list);
        rel.setAdapter(adapter);
    }

    @Override
    protected SectionsPresenter initPresenter() {
        return new SectionsPresenter();
    }

    @Override
    public void setData(List<columnBean.DataBean> data) {
        adapter.addData(data);
    }
}
